package com.uuuo.rxjava1;

import org.junit.Test;

import rx.Observable;
import rx.functions.Action1;
import rx.functions.Func1;

/**
 * Created by JiaTao on 2017/4/1.
 */

public class C_Filter extends A_Base {
    @Test
    public void filter() {
        Observable.range(1, 8)
                .filter(new Func1<Integer, Boolean>() {
                    @Override
                    public Boolean call(Integer integer) {
                        return integer % 2 == 0;
                    }
                })
                .subscribe(new Action1<Integer>() {
                    @Override
                    public void call(Integer integer) {
                        showMsg(integer + "");
                    }
                });
    }

    @Test
    public void takeLast() {
        Observable.range(1, 6)
                .takeLast(3)
                .subscribe(new Action1<Integer>() {
                    @Override
                    public void call(Integer integer) {
                        showMsg(integer + "");
                    }
                });
    }
}
